package com.xms.configuration.api.controller;

import com.xms.core.annotation.AllowAnonymous;
import com.xms.core.model.KeyValuePair;
import com.xms.utils.JsonUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * GlobalSettingsController
 * </p>
 *
 * @author migo
 * @since 2021/11/6
 */
@RestController
@RequestMapping("/api/global/settings")
public class GlobalSettingsController {
    @Value("${xms.appname}")
    public String appName;

    @AllowAnonymous
    @ApiOperation("获取全局参数")
    @GetMapping("")
    public String get(){
        KeyValuePair pairs = KeyValuePair.build("appname", appName);
        String result = String.format("var GLOBAL_SETTINGS = %s;", JsonUtil.toJSONString(pairs));
        return result;
    }
}
